import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_juwo/common/common_index.dart';
import 'package:flutter_juwo/ui/utils/progress_view.dart';

class PhotoHeroNet extends StatelessWidget {
  const PhotoHeroNet({ Key key, this.photo, this.onTap, this.width }) : super(key: key);

  final String photo;
  final VoidCallback onTap;
  final double width;

  Widget build(BuildContext context) {
    return new SizedBox(
      width: width,
      child: new Hero(
        tag: photo,
        child: new Material(
          color: Colors.transparent,
          child: new InkWell(
            onTap: onTap,
            child: CachedNetworkImage(
              width: width,
              height: width,
              fit: BoxFit.contain,
              imageUrl: photo,
              placeholder: (context, url) => new ProgressView(width: width,),
              errorWidget: (context, url, error) => new Icon(
                Icons.error,
                color: Colors.redAccent,
              ),
            ),
          ),
        ),
      ),
    );
  }
}
